package de.fuberlin.inf.alp4.uebg5;

import java.util.concurrent.Callable;

/**
 * This class represents MessageRequests which will eventually free the M1-Requests
 * @author reim
 *
 */
public final class M2Request extends MessageRequest<Integer> {

    /* The request might hold attributes for the parameter and
       the method <code>guard()</code> may be overridden here.

        The constructor initialises the servant field provided in the super
        class and creates a new callable instance, that, on dispatch, calls
        its method on the servant object. This is convenient, because
        a conventional object may be converted to an active one with minimal
        effort. */
    public M2Request(final Servant servant, int priority) {
		super(servant, 
				new Callable<Integer>() {
	                           public Integer call() { return servant.m2(); }
	            }, priority);
    }

	public boolean guard() {
		return (this.servant.m2()%2 == 0);
	}
	
	public String getRequestType() {
		return "M2";
	}
    
}
